<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <a href="#/home">home</a>
    <a href="#/about">about</a>
    <div id="app"></div>
  </body>
</html>
<script>
  let arr = [
    { path: "#/home", component: `<div>我是首页</div>` },
    { path: "#/about", component: `<div>我是about</div>` },
  ];
  // console.log(window);
  // console.log(document);
  let dom = document.querySelector("#app");
  window.onhashchange = function (e) {
    // 直接获取 地址栏 location.hash 后面的东西
    // console.log(location.hash);
    let obj = arr.find((item) => item.path == location.hash);
    dom.innerHTML = obj.content;
  };

  function Start(val) {
    this.name = val;
    console.log(this);
  }
  let obj = new Start("张三");
  console.log(obj);
</script>
